<template>
<view-box style="background:#F3F6F7;">
<div class="address-search">
      <router-link to="/jobsearch" class="search-div">
        <i class="search-icon iconfont icon-sousuo" style="font-size: 20px;"></i>
        <p class="search-String">天南山</p>
      </router-link>
      <!-- <div class="ident" v-if="identity === '2'" @click="$router.push('/issue')">发布职位</div> -->
    </div>
    <div style="height: 55px;background:#fff;"></div>
    <swiper auto loop class="add-cong" dots-position="center" :aspect-ratio="1/2" :list="list" v-if="list.length > 0"></swiper>
    <div style="height:30px;background:#fff;"></div>
    <div class="background-top-pos">
      <div class="lucency">
        <div class="bac-thou-cong">
        <div class="text-centers" @click="$router.push('/paixielit?rouiy=' + 'vip_over_time')">
            <p><i slot="icon" style="color:#4F7478;font-size:20px;position: relative;top:2px;" class="icon-remenzhiye iconfont"></i></p>
            <p style="color: #4F7478"> 会员精选</p>
        </div>
        <p style="height: 30px;width: 1px; background: #e6e6e6;margin:10px 0px;"></p>
        <div class="text-centers" @click="$router.push('/paixielit?rouiy=' + 'graded')">
            <p><i slot="icon" style="color:#4F7478;font-size:20px;position: relative;top:2px;" class="icon-youzhiqiye iconfont"></i></p>
            <p style="color: #4F7478"> 信用分</p>
        </div>
        <p style="height: 30px;width: 1px; background: #e6e6e6;margin:10px 0px;"></p>
        <div class="text-centers" @click="$router.push('/paixielit?rouiy=' + 'updated_at')">
            <p><i slot="icon" style="color:#4F7478;font-size:20px;position: relative;top:2px;" class="icon-mianshi iconfont"></i></p>
            <p style="color: #4F7478"> 最新</p>
        </div>
        </div> 
     </div>
     <div style="height:20px;"></div>
     <div class="co-laou" v-for="(item, index) in items" :key="index" @click="$router.push('/previewLouw?id=' + item.user_id)" v-if="item.basic !== null">
        <div class="co-lib">
            <div class="co-dilkp">
                <p style="font-size:15px;color:#000;font-weight: 600;" v-if="item.basic === null">未知职位</p>
                <p style="font-size:15px;color:#000;font-weight: 600;" v-if="item.basic !== null">{{item.basic.company}}</p>
                <p style="font-size:13px;color:#BABABA;" >{{item.basic.city}} | {{birth - item.basic.start_work_time}}年 | {{item.work_number_count}}段工作经验</p>
            </div>
            <div class="co-dilk">
                <p style="font-size:15px;color:#32B6C6;font-weight: 600;" v-if="item.basic !== null && item.basic.is_look_annual_salary === 1">{{item.basic.annual_salary}}</p>
                <p style="font-size:15px;color:#32B6C6;font-weight: 600;" v-if="item.basic !== null && item.basic.is_look_annual_salary === 0">保密</p>
                <p style="font-size:13px;color:#BABABA;">{{item.created_at | formatDate}}</p>
            </div>
        </div>
        <div class="co-bott-om">
           <div class="work-job-lj">
                <p style="color: #ff0000;font-weight: 600;width:100%;">
                  <img style="width:66px;height:66px;border-radius: 7px;" :src="item.user.avatar" alt="">
                </p>
            </div>
            <div class="work-job-cl" >
                <p class="job-pol-col" style="font-size:13px;color:#000;font-weight: 0;">{{item.basic.true_name}}</p>
                <p class="job-pol-col" style="font-size:13px;color:#BABABA;font-weight: 0;">{{item.basic.now_status}}</p>
            </div>
        </div>
     </div>
      <infinite-loading @infinite="infiniteHandler" ref="infiniteLoading">
        <load-more slot="no-more" :show-loading="false" tip="到底了" background-color="#fbf9fe"></load-more>
        <empty slot="no-results" tips="暂时没有相关内容"></empty>
      </infinite-loading>
    </div>
  <b-menu selected="talents"></b-menu>
</view-box>
</template>
<script>
import bMenu from '../components/bottom_menu'
import { ViewBox, Box, Flexbox, FlexboxItem, Divider, Swiper } from 'vux'
import { formatDate } from '../../utils/index.js'
// import { log } from 'util';

export default {
  components: {
    ViewBox,
    Box,
    bMenu,
    Flexbox,
    FlexboxItem,
    Divider,
    Swiper
  },
  data () {
    return {
      entrance: {
        identity: 0,
        motto: null,
        position: null,
        interview: 0,
        sex: 0
      },
      identity: 0,
      items: [],
      ads: []
    }
  },
  filters: {
    formatDate (time) {
      var date = new Date(time)
      return formatDate(date, 'yyyy-MM-dd')
    }
  },
  computed: {
    list () {
      let data = []
      this.ads.forEach((item) => {
        data.push({
          img: this.$apiUrl + '/storage/' + item.body,
          url: item.url
        })
      })
      return data
    },
    birth: function () {
      let mydate = new Date()
      let newdate = mydate.getFullYear()
      console.log(newdate)
      return newdate
    }
  },
  mounted () {
    this._getAds()
    this.interview = localStorage.getItem('interview')
    let cat = localStorage.getItem('identity')
    this.identity = cat
    console.log(this.identity)
  },
  methods: {
    dianclick (id) {
      localStorage.setItem('interview', id)
      this.$router.push({path: '/Details/?rid=' + id})
    },
    infiniteHandler ($state) {
      this.$http.get('/talentsRecommend', {
        params: {
          page: this.items.length / 20 + 1,
          page_size: 20
        }
      }).then((response) => {
        if (response.data.data.length) {
          console.log(1212)
          this.items = this.items.concat(response.data.data)
          $state.loaded()
          if (!response.data.next_page_url) {
            $state.complete()
          }
        } else {
          $state.complete()
        }
      })
    },
    _getAds () {
      this.$http.get('/ads?position=9&page_size=5&order_by=order&order_type=asc').then((response) => {
        this.ads = response.data.data
      })
    }
  }
}
</script>
<style scoped>
  .address-search {
    height: 50px;
    width: 100%;
    font-size: 16px;
    position: fixed;
    z-index: 999;
    top: 0;
    display: flex;
    background-color: #fff;
  }
  .address-div {
    width: 25%;
    padding-left: 5px;
    height: 50px;
    line-height: 50px;
    display: flex;
    -webkit-box-pack: center;
    justify-content: center;
  }
  .co-dilk{
    width: 40%;
    text-align: right;
  }
  .co-dilkp{
    width: 60%;
  }
  .address-icon {
    color: #595959;
    margin-left: 6px;
    padding-right: 6px;
  }
  .address-title {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #878787;
  }
  .xaddress {
    display: none;
  }
  .search-div {
    width: 94%;
    line-height: 30px;
    display: flex;
    height: 30px;
    margin-top: 10px;
    margin-left: 3%;
    background-color: #f2f2f2;
    border-radius: 20px;
  }
  .search-icon {
    color: #8e8e8e;
    margin-left: 5%;
    font-size: 20px;
  }
  .search-String {
    color: #bebebe;
    margin-left: 5%;
    font-size: 15px;
  }
.background-top-pos{
  position: relative;
  background: #F3F6F7;
  height: auto;
  width: 100%;
}
.bac-thou-cong{
    width: 100%;
    display: flex;
    justify-content: space-evenly;
}
.co-laou{
width: 92%;
margin-left: 4%;
background: #fff;
opacity: 0.8;
height: auto;
margin-top: 10px;
border-radius: 7px;
}
.co-lib{
    display: flex;
    width: 92%;
    margin-left: 4%;
    border-bottom: 1px solid rgba(0,0,0,0.1);
    padding-top: 20px;
    padding-bottom: 10px;
}
.co-bott-om{
  display: flex;
  width: 92%;
  margin-left: 4%;
  padding-top: 5px;
  padding-bottom: 5px;
}
.lucency{
    width: 92%;
    margin-left: 4%;
    background: #fff;
    opacity: 0.8;
    height: auto;
    border-radius: 7px;
    position: absolute;
    box-shadow: 1px 1px 6px 0.2px rgba(0,0,0,0.2);
    top: -30px;
    left: 0;
}
.lucency a{
  color: #000;
}
.text-centers{
    display: flex;
    width: 33%;
    align-items: center;
    justify-content: center;
}
.flex-dh-cl{
    padding-top: 10px;
    line-height: 20px;
    text-align: center;
}
.flex-dh-cl img{
    width: 40% !important;
}
.flex-dh-cl p{
    font-size: 15px;
    font-weight: 600;
}
.font-col-cl{
    font-size: .0864rem;
    background: #fff;
    position: relative;
    bottom: -28.8px;
}
.bottom-clo-cl{
}
.tjian-cl{
    background: #fff;
    display: flex;
    width: 100%;

}
.work-job-lj {
    width: 25%;
    display: flex;
    align-items: center;
}
.work-job-lj p{
    font-size: 15px;

}
.work-job-cl{
  width: 75%;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
}
.job-pol-col{
  width: 100%;
  font-weight: 600;
}
.work-job-cl p{
  text-align: left;
  font-size: 15px;
}
.member{
  color: #fff;
  background: #e5191a;
  padding: 1px;
  margin-right: 7.2px;
}
.ident{
  width: 35%;
  height: 50px;
  line-height: 50px;
  text-align: center
}
.add-cong{
    padding-bottom: 30px;
    background: #fff;
}
</style>
<style>
.add-cong.vux-slider > .vux-swiper {
    overflow: hidden;
    position: relative;
    width: 92%;
    margin-left: 4%;
    border-radius: 8px;
}
.add-cong.vux-slider > .vux-indicator > a > .vux-icon-dot, .vux-slider .vux-indicator-right > a > .vux-icon-dot {
    display: inline-block;
    vertical-align: middle;
    width: 12px!important;
    height: 3px!important;
    border-radius: 0px!important;
    background-color: #d0cdd1;
}
.add-cong.vux-slider > .vux-indicator > a > .vux-icon-dot.active, .vux-slider .vux-indicator-right > a > .vux-icon-dot.active {
    background-color: #55D4E3!important;
}
</style>